package com.timepies.domain;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Timepie implements Serializable {

	private static final long serialVersionUID = 5312478258085108341L;

	private long id;
	private Date rowDate;
	private String data = "";
	private String oggetto = "";
	private String testo = "";
	private String owner = "";
	private String jsonId = "";

	public Timepie() {
		super();
	}

	public Timepie(long id, String data, String oggetto, String testo) {
		super();
		try {
			this.id = id;
			this.data = data;
			this.oggetto = oggetto;
			this.testo = testo;
			this.rowDate = Intervallo.date.parse(data);
		} catch (ParseException e) {
		}
	}

	public Timepie(Festivita festa, int year) {
		int giorno = festa.getGiorno();
		int month = festa.getMese() - 1;
		Calendar c = GregorianCalendar.getInstance();
		c.set(year, month, giorno, 0, 0, 0);
		this.id = c.get(Calendar.DAY_OF_YEAR);
		this.rowDate = c.getTime();
		this.data = Intervallo.date.format(rowDate);
		this.testo = Intervallo.title.format(rowDate);
		this.oggetto = festa.getDescrizione();
	}

	public Timepie(Date date, String string) {
		Calendar c = GregorianCalendar.getInstance();
		c.setTime(date);
		this.id = c.get(Calendar.DAY_OF_YEAR);
		this.rowDate = c.getTime();
		this.data = Intervallo.date.format(rowDate);
		this.testo = Intervallo.title.format(rowDate);
		this.oggetto = string;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public String getOggetto() {
		return oggetto;
	}

	public void setOggetto(String oggetto) {
		this.oggetto = oggetto;
	}

	public String getTesto() {
		return testo;
	}

	public void setTesto(String testo) {
		this.testo = testo;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getRowDate() {
		return rowDate;
	}

	public void setRowDate(Date rowDate) {
		this.rowDate = rowDate;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getJsonId() {
		return jsonId;
	}

	public void setJsonId(String jsonId) {
		this.jsonId = jsonId;
	}

}
